package com.sikadwafastdaisfondturbo.pretloan.adapter

import android.view.View
import androidx.recyclerview.widget.RecyclerView
import com.sikadwafastdaisfondturbo.lib_baseadapter.SikadwaRecyclerViewAdapter
import com.sikadwafastdaisfondturbo.lib_baseadapter.SikadwaViewHolderHelper
import com.sikadwafastdaisfondturbo.pretloan.R
import org.json.JSONObject

/**
 * Sikadwa
 * @Author wwdeng
 * @CreateTime: 2024/4/19 12:02
 * @Annotation：客服 - 联系方式列表
 */
class KefuContactAdapter(recyclerView: RecyclerView?): SikadwaRecyclerViewAdapter<JSONObject>(recyclerView,R.layout.item_kefu_contact) {

    override fun setItemChildListener(helper: SikadwaViewHolderHelper, viewType: Int) {
        helper.setItemChildClickListener(R.id.btnDial)//拨号
    }

    override fun fillData(helper: SikadwaViewHolderHelper, position: Int, model: JSONObject) {
        helper.setText(R.id.textContent,model.optString("value"))

        val type = model.optString("type")
        when(type){
            "MOBILE" -> {//电话
                helper.setText(R.id.textType,mContext.getString(R.string.login_phone_number))
                helper.setVisibility(R.id.btnDial, View.VISIBLE)
            }
            else -> {//邮箱
                helper.setText(R.id.textType,mContext.getString(R.string.kefu_e_mail))
                helper.setVisibility(R.id.btnDial, View.GONE)
            }
        }

        if (position == itemCount - 1){
            helper.setVisibility(R.id.vLine, View.GONE)
        } else {
            helper.setVisibility(R.id.vLine, View.VISIBLE)
        }
    }
}